using System;
using System.Collections.Generic;
using System.Text;
using Universe.Remoting.Extensions;

namespace Universe.Remoting.Tests
{
    static class MyServerInit
    {
        public const int Port = 40987;
        static Locator Locator = new Locator(Port);

        static ServerRepository Repository =
            new ServerRepository()
                .Register<IMySingleCall, MyServer>()
                .Register<IMySingleton, MyServer>(new MyServer());

        static RemotingPublisher Publisher = new RemotingPublisher();

        public static void Run()
        {
            TransparentDeliveryConfiguration.OnServer +=
                delegate(DeliveryDictionary data)
                {
                    LastTransparentValue = data.Get<int>("My Int");
                };

            Publisher.Publish(Repository, Locator);
        }

        public static void Close()
        {
            Publisher.Disconnect(Repository, Locator);
        }

        public static int LastTransparentValue;

    }
}
